#include <gtk/gtk.h>

#include "GTWindow.h"
#include "GToolBar.h"
#include "GWindowMgr.h"
/* Timeout handler to regenerate the frame */
static gint timeout ( gpointer data );
static guint timeout_id;
#define FRAME_DELAY 50

int main(int argc, char *argv[])
{

	CGToolBar gtWindow;

	gtk_init(&argc, &argv);

	add_pixmap_directory("resource/texture");
	gtWindow.create("resource/texture/background.png");
	timeout_id = g_timeout_add (FRAME_DELAY, timeout, NULL);

	gtk_main();
	return TRUE;
}

static gint timeout ( gpointer data )
{
	CGWindowMgr::getSingletonPtr()->advanceTime(0.02f);
	return TRUE;	
}

//cairo_surface_t *image = NULL; 
//
//static gboolean on_window_expose_event(GtkWidget * widget,
//									   GdkEventExpose * event, gpointer data)
//{
//	cairo_t *cr;
//
//	cr = gdk_cairo_create(widget->window);
//	cairo_set_source_surface(cr, image, 0, 0);
//	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
//	cairo_paint(cr);
//	cairo_destroy(cr);
//	return FALSE;
//}
//
//gint main(gint argc, gchar ** argv)
//{
//	GtkWidget *window;
//	GdkScreen *screen;
//	GdkColormap *colormap;
//
//	gtk_init(&argc, &argv);
//
//	image = cairo_image_surface_create_from_png("demo3.png");
//	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//	gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
//	gtk_widget_set_app_paintable(window, TRUE);
//	gtk_window_resize(GTK_WINDOW(window), 250, 250);
//	g_signal_connect(G_OBJECT(window), "expose-event",
//		G_CALLBACK(on_window_expose_event), NULL);
//
//	screen = gtk_widget_get_screen(window);
//	colormap = gdk_screen_get_rgba_colormap(screen);
//	gtk_widget_set_colormap(window, colormap);
//
//	gtk_widget_show_all(window);
//	gtk_main();
//	return TRUE;
//}

